
import { _polar, _atan, _dis } from '../index.js'
import { eachNext, _type } from '../../utils/index.js'
// 线段分割： 分割数量
export const linePoints = (p1, p2, n) => {
    let r = _dis(p1, p2)
    let a = _atan(p1, p2)
    return Array.from({
        length: n
    }, (_, index) => _polar(p1, index * r / n, a))
}

// 折线
export const polylinePoints = (points, options = {}) => {
    let { m = 100 } = options
    let ps = []
    eachNext(points, (t, index, next) => {
        ps.push(...linePoints(t, next, m))
    })
    return ps

}